// 导入二次封装axios
import koi from "@/utils/axios.ts";
import { ITableParams } from "./type.ts";

// 统一管理接口
enum API {
  LIST_PAGE = "/platform/system/role/list",
  GET_BY_ID = "/platform/system/role/getById",
  UPDATE = "/platform/system/role/update",
  ADD = "/platform/system/role/add",
  DELETE = "/platform/system/role/deleteById",
  BATCH_DELETE = "/platform/system/role/batchDelete",
  UPDATE_STATE = "/platform/system/role/updateStatus",
  LIST_NORMAL_ROLE = "/platform/system/role/listNormalRole",
  ASSIGN_USER_ROLE = "/platform/system/role/assignUserRole"
}
// 多条件分页查询数据
export const listPage = (params: ITableParams) => {
  return koi.get(API.LIST_PAGE, params);
};

// 查询所有正常角色[穿梭框]
export const listNormalRole = (id: any) => {
  return koi.get(API.LIST_NORMAL_ROLE, { id });
};

// 根据ID进行查询
export const getById = (id: any) => {
  return koi.get(API.GET_BY_ID, { id });
};

// 根据ID进行修改
export const update = (data: any) => {
  return koi.post(API.UPDATE, data);
};

// 添加
export const add = (data: any) => {
  return koi.post(API.ADD, data);
};

// 删除
export const deleteById = (id: any) => {
  return koi.post(API.DELETE, { id });
};

// 批量删除
export const batchDelete = (ids: any) => {
  return koi.post(API.BATCH_DELETE, { ids }); // 第一种传参方式
};

// 修改状态
export const updateStatus = (id: any, status: any) => {
  return koi.post(API.UPDATE_STATE, { id, status }); // 第一种传参方式
};

// 根据当前用户ID分配角色
export const assignUserRole = (id: any, roleIds: any) => {
  return koi.post(API.ASSIGN_USER_ROLE, { id, roleIds }); // 第一种传参方式
};
